// pages/news/news.js

Page({
  data: {
    content: [],
  },
  onShow: requestNews,
  onReachBottom: requestNews
});

var APIKEY = "1d574ffc1e47fa65274294e074b361f1";
var page = 1;

function requestNews() {
  var _this = this;
  var content = this.data.content;
  wx.request({
    url:
      "https://api.tianapi.com/lajifenleinews/index?key=" +
      APIKEY +
      "&num=10" + "&page=" + page,
    success: function (res) {
      if (res.data.code == 200) {
        _this.setData({
          content: content.concat(res.data.newslist),
        });
      } else {
        _this.setData({
          content: res.data.msg,
        });
      }
    },
    fail: function (err) {
      console.log(err);
    },
  });
  page++;
}